{{template "header.html" .UIUtils.Slice "Go Search API" "api"}}
{{define "apibody"}}
### Introduction

Go Search API, or GSAPI, returns structured data with json or jsonp format.

The path of GSAPI is "`/api`".

Please put a link to http://go-search.org/ on you website if this API helps you.

### Shared parameters

Field      | Value
-----------|------------------------------------------------------------------
`action`   | Possible values: `package`, `tops`, `packages`
`callback` | (optional) If provided, return jsonp code with this as the callback function. <br> The callback function has two parameters. First parameter is an integer of code, and the second is the value object returned.<br>[example](/api?action=tops&callback=myfunc)

### "package" Action

Returns the information of a package. [example](/api?action=package&id=github.com%2fdaviddengcn%2fgcse)

* Parameters

    Field    | Value
    ---------|-----------------------------------------------------------------
    `action` | `package`
    `id`     | The ID of the package. Same as the string used to import

* Return value

    Field         | Type       | Value
    --------------|------------|-----------------------------------------------
    `Package`     | `string`   | Import path, ID of a package in GS
    `Name`        | `string`   | Package name
    `StarCount`   | `int`      | Number of stars(github, bitbucket, plus/like buttons)
    `Synopsis`    | `string`   | Synopsis(from package comment or documentaion)
    `Description` | `string`   | Detailed documents
    `TestImported`| `[]string` | List of packages that imports this package only in test cases.
    `Imported`    | `[]string` | List of packages that imports this package
    `TestImports` | `[]string` | List of packages this package (only) test imports
    `Imports`     | `[]string` | List of packages this package imports
    `ProjectURL`  | `string`   | URL of the project of this package
    `StaticRank`  | `int`      | Static rank of this package. One-based.


### "tops" Action

Returns the [tops](/tops) tables. [example](/api?action=tops)

* Parameters

    Key      | Value
    ---------|------------------------------------------------------------------
    `action` | `tops`
    `len`    | (optional) The maximum number of entries in each table. Limited to [20, 100].

* Return value (An array of tables)

    Field   | Type       | Value
    --------|------------|-----------------------------------------------
    `Name`  | `string`   | Table title
    `Info`  | `string`   | Top right comments
    `Items` | `[]`       | Items of the table. For each item:<br> `Name` is the anchor text,<br> `Package` is the package import path,<br> `Link` is the URL if the item is not a package,<br> `Info` is the information text on the second column


### "packages" Action

Returns the ID array of all packages. [link](/api?action=packages)

* Parameters

    Key      | Value
    ---------|------------------------------------------------------------------
    `action` | `packages`

* Return values

An array of strings, each of which is the ID (or import path) of a package.


### "package_depends" Action

Returns an array of dependency information of all packages. [link](/api?action=package_depends)

* Parameters

    Key      | Value
    ---------|------------------------------------------------------------------
    `action` | `package_depends`

* Return values

An array of the following struct:

   Field         | Type       | Value
  ---------------|------------|-----------------------------------------------------------------
   `Package`     | `string`   | Import path, ID of a package in GS
   `Name`        | `string`   | Package name
   `TestImported`| `[]string` | List of packages that imports this package only in test cases.
   `Imported`    | `[]string` | List of packages that imports this package
   `TestImports` | `[]string` | List of packages this package (only) test imports
   `Imports`     | `[]string` | List of packages that imports this package


### "search" Action

Returns the search result. [example](/api?action=search&q=gcse)

* Parameters

    Key      | Value
    ---------|------------------------------------------------------------------
    `action` | `search`
    `q`      | the query

* Return values

    Field   | Type       | Value
    --------|------------|-----------------------------------------------
    `query` | `string`   | the search query
    `hits`  | `[]`       | Hit entries. For each item:<br> `name` is the name of the project,<br> `package` is the package import path,<br> `projecturl` is the URL if the item is not a package,<br> `author` is the author name of the project, <br> `synopsis` is the brief introduction of the project, <br> `description` is the detailed introduction of the project.


{{end}}
<div class="markdown">
{{markdown "apibody"}}
</div>
{{template "footer.html"}}
